﻿namespace TradePublish.Dao
{
    using TradePublish.Common;
    using log4net;
    using System;
    using System.Data.SqlClient;
    using System.Reflection;
    using System.Threading;
    using TradePublish.Service;

    internal class DissentStatusSerchDao
    {
        private ILog log = null;

        public DissentStatusSerchDao()
        {
            this.log = log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
        }

        public void saveStatusSearchResult(int tradePublishId)
        {
            while (true)
            { 
                if (DateTime.Now.Hour == 6 && DateTime.Now.Minute < 30  || (DateTime.Now.Hour >=8 && DateTime.Now.Hour <18  &&  Convert.ToInt32(DateTime.Now.DayOfWeek) !=0 && Convert.ToInt32(DateTime.Now.DayOfWeek) !=6   ) )
                {
                    Thread.Sleep(180000);//3fenzhong  
                    continue;
                }

                DatabaseHelper dbh = new DatabaseHelper();
                try
                {
                    dbh.ExecuteNonQuery("insert into DISSENT_STATUS_SEARCH  (id,TRADE_PUBLISH_ID) values(gen_sequence.nextval," + tradePublishId + ")");
                    return;
                }
                catch (Exception exception)
                {
                    this.log.Error("插入异议状态查询异常.", exception);
                    Thread.Sleep(0x3e8);
                }
                finally
                {
                    dbh.Dispose();
                }
            }
        }
    }
}

